#pragma once

#define signals protected




class EditWidget : public QWidget
{
	Q_OBJECT

public:

	QAbstractItemView*   m_itemView;
	QModelIndex          m_index;

public:

	EditWidget(QAbstractItemView* itemView, const QModelIndex& index);
	virtual ~EditWidget();



	QAbstractItemView* itemView() const;
	QModelIndex index() const;



	/**
	 * Must return if the data in the widget has been changed since the last call to apply.
	 */
	virtual bool hasChanged() const = 0;

	/**
	 * Tests if the contained & edited data belongs to the item in the given view with the given model index.
	 */
	bool belongsToView(QAbstractItemView* itemView, const QModelIndex& index) const;



	/**
	 * When called, a subclass must apply all the changes made to the actual data.
	 */
	virtual void apply() const = 0;

	/**
	 * When called, a subclass must fetch all data from the original data (thus everything
	 * done since the last apply() is lost.
	 */
	virtual void discard() = 0;

signals:


	/**
	 * This signal is emitted when the user changed something in the widget.
	 */

	void changed();
};
///////////////////////////////////////////////////////////////////////////////////////////////////
